<?php                                
  require(dirname(__FILE__).'/global.php');
  require(ROOT.'/admin/isLogin.php');    
  require(ROOT.'/include/xml.class.php'); 
  
  $submit = $_POST['submit'];
  $xmlPath = ROOT.'/common.xml';
  $xml = new SimpleXMLUtil($xmlPath);
  if(isset($submit))
  {
      $isAllowRegister = $_POST['isAllowRegister'];
      $isAllowRegister = empty($isAllowRegister) ? 'y' : $isAllowRegister;
      $register_page = $_POST['register_page'];
      $register_approve = $_POST['register_approve'];
      $register_content = $_POST['register_content'];
      $rule = $_POST['rule'];
      $rule = empty($rule) ? 'y' : $rule; 
      
      $xml->setElementValue('Register',$isAllowRegister);
      $xml->setElementValue('RegisterPage',$register_page);
      $xml->setElementValue('Approve',$register_approve);
      $xml->setElementValue('Content',$register_content);
      $xml->setElementValue('Rule',$rule);  
      $xml->save();
                                    
      $smarty->assign('tip','更新成功');
  }
  $isAllowRegister = $xml->getElementValue("Register") ? $xml->getElementValue("Register") : 'y';
  $register_page = $xml->getElementValue("RegisterPage");
  $register_approve = $xml->getElementValue("Approve") ? $xml->getElementValue("Approve") : 'email' ;  
  $register_content = $xml->getElementValue("Content"); 
  $rule = $xml->getElementValue("Rule") ? $xml->getElementValue("Rule") : 'y';
      
  $smarty->assign('isAllowRegister',$isAllowRegister);
  $smarty->assign('register_page',$register_page);
  $smarty->assign('register_approve',$register_approve);
  $smarty->assign('register_content',$register_content);
  $smarty->assign('rule',$rule);
  $smarty->display('access.html'); 
  $db->close();
?>